<?php

class FP_View_Helper_Months
{
  const NUMBER_LEADING_ZERO = 0;
  const NUMBER = 1;
  const ABBREVIATED_NAME = 2;
  const NAME = 3;

  protected $abbreviations = array(1 => 'Jan',
                                   2 => 'Feb',
                                   3 => 'Mar',
                                   4 => 'Apr',
                                   5 => 'May',
                                   6 => 'Jun',
                                   7 => 'Jul',
                                   8 => 'Aug',
                                   9 => 'Sep',
                                   10 => 'Oct',
                                   11 => 'Nov',
                                   12 => 'Dec');

  protected $names = array(1 => 'January',
                           2 => 'February',
                           3 => 'March',
                           4 => 'April',
                           5 => 'May',
                           6 => 'June',
                           7 => 'July',
                           8 => 'August',
                           9 => 'September',
                           10 => 'October',
                           11 => 'November',
                           12 => 'December');

  protected function getMonth($pNumber, $pFormat){
    switch ($pFormat){
    case self::NUMBER_LEADING_ZERO:
      return sprintf('%02d', $pNumber);
    case self::NUMBER:
      return $pNumber;
    case self::ABBREVIATED_NAME:
      return $this->abbreviations[$pNumber];
    case self::NAME:
      return $this->names[$pNumber];
    }
  }

  public function months($pTextFormat=self::NAME, $pValueFormat=self::NUMBER_LEADING_ZERO){
    return array($this->getMonth(1, $pValueFormat) => $this->getMonth(1, $pTextFormat),
                 $this->getMonth(2, $pValueFormat) => $this->getMonth(2, $pTextFormat),
                 $this->getMonth(3, $pValueFormat) => $this->getMonth(3, $pTextFormat),
                 $this->getMonth(4, $pValueFormat) => $this->getMonth(4, $pTextFormat),
                 $this->getMonth(5, $pValueFormat) => $this->getMonth(5, $pTextFormat),
                 $this->getMonth(6, $pValueFormat) => $this->getMonth(6, $pTextFormat),
                 $this->getMonth(7, $pValueFormat) => $this->getMonth(7, $pTextFormat),
                 $this->getMonth(8, $pValueFormat) => $this->getMonth(8, $pTextFormat),
                 $this->getMonth(9, $pValueFormat) => $this->getMonth(9, $pTextFormat),
                 $this->getMonth(10, $pValueFormat) => $this->getMonth(10, $pTextFormat),
                 $this->getMonth(11, $pValueFormat) => $this->getMonth(11, $pTextFormat),
                 $this->getMonth(12, $pValueFormat) => $this->getMonth(12, $pTextFormat),
                 );
  }
}

?>